<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="/static/layui/extend/steps/steps.css" />
    <#include "/common/base.ftl"/>
    <script src="/static/layui/layui.js" charset="utf-8"></script>
    <script src="/static/layui/config.js"></script>
    <style>
        .step-list {
            max-width: 1000px;
            margin: 0 auto;
            text-align: center;
            background: #5a7cfb;
            color: #fff;
            margin-bottom: 20px;
            font-size: 50px;
            line-height: 300px;
        }
        .step-header {
            margin-top: 30px;
            margin-bottom: 30px;
        }
        table, tr, td{
            border: 0px !important;
        }
        td{
            width: 33%;
        }
        .pic{
            width: 200px;
            height: 200px;
        }
        textarea{
            min-height: 60px;
            border-radius: 0 0 2px 2px;
            line-height: 14px;
            padding: 6px 10px;
            resize: vertical;
            border-width: 1px;
            border-style: solid;
            background-color: #fff;
        }
    </style>
</head>
<body>

<div class="wrapper wrapper-content">
    <div class="col-sm-12" id="app_form">
        <#--<div class="row">
            <div class="col-sm-12">
                <div id="step_demo" class="step-body">
                    <div class="step-header"></div>
                </div>
            </div>
        </div>-->

        <div class="row">
            <div class="col-sm-12">
                <fieldset>
                    <legend style="font-size: 15px">申请信息</legend>
                    <table class="table table-hover no-margins no-borders">
                        <tr>
                            <td>申请编号：<label id="uuid"></label></td>
                            <td >业务类型：<label id="transType"></label></td>
                            <td >申请时间：<label id="createTime" class="dtime"></label></td>
                        </tr>
                        <tr>
                            <td>医院简称：<label id="hospName"></label></td>
                            <td >微信昵称：<label id="userInfo_nickname"></label></td>
                            <td ></td>
                        </tr>
                        <#--<tr>
                            <td>备注：<label id="brf"></label></td>
                            <td ></td>
                            <td ></td>
                        </tr>-->
                    </table>

                    <legend style="margin-top: 20px;font-size: 15px">基本信息</legend>
                    <table class="table table-hover no-margins no-borders">
                        <tr>
                            <td>手机号：<label id="mobile"></label></td>
                            <td >住院号：<label id="cureNo"></label></td>
                            <td >患者姓名：<label id="idCard_idcName"></label></td>
                        </tr>
                        <tr>
                            <td>身份证：<label id="idCard_idcNo"></label></td>
                            <td >入院时间：<label id="startTime" class="dtime"></label></td>
                            <td >出院时间：<label id="endTime" class="dtime"></label></td>
                        </tr>
                        <tr>
                            <td>科室病区：<label id="depName"></label></td>
                            <td >发票：<label id="fp">不需要</label></td>
                            <td >打印次数：<label id="printCount"></label></td>
                        </tr>
                    </table>

                    <legend style="margin-top: 20px;font-size: 15px">验证信息</legend>
                    <table class="table table-hover no-margins no-borders">
                        <tr>
                            <td>正面照：<img id="idCard_picUrl1" class="pic" src="" alt="正面照"/></td>
                            <td >反面照：<img id="idCard_picUrl2" class="pic" src="" alt="反面照"/></td>
                            <td >手持照：<img id="idCard_picUrl3" class="pic" src="" alt="手持照"/></td>
                        </tr>
                    </table>

                    <legend style="margin-top: 20px;font-size: 15px">审核信息</legend>
                    <div class="layui-tab layui-tab-brief" lay-filter="tab-verify">
                        <ul class="layui-tab-title">
                            <li class="layui-this" id="pass">审核通过</li>
                            <li id="refuse">审核拒绝</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <table class="table table-hover no-margins no-borders verify-pass-table">
                                    <tr>
                                        <td>单份金额：<input placeholder="￥" type="text" class="ipt" name="singlePrice" value="0" style="width: 60px;" onchange="calPrice();"> 元</td>
                                        <td>邮寄费用：<input placeholder="￥" type="text" class="ipt" name="transPrice" value="0" style="width: 60px;" onchange="calPrice();"> 元</td>
                                        <td>手续费：<input placeholder="￥" type="text" class="ipt" name="extraPrice" value="1.00" style="width: 60px;" readonly> 元</td>
                                    </tr>
                                    <tr>
                                        <td>总金额：<label name="totalPrice" style="font-weight: bold; font-size: 16px; color:red;">0.00</label> 元</td>
                                        <td colspan="2">审核意见：<textarea id="option" placeholder="请输入审核意见" name="option" style="width: 300px;"></textarea></td>
                                    </tr>
                                </table>
                            </div>
                            <div class="layui-tab-item">
                                <table class="table table-hover no-margins no-borders verify-table verify-refuse-table">
                                    <tr>
                                        <td>单份金额：<input type="text" name="singlePrice" value="0" style="width: 60px;" onchange="calPrice();" disabled> 元</td>
                                        <td>邮寄费用：<input type="text" name="transPrice" value="0" style="width: 60px;" onchange="calPrice();" disabled> 元</td>
                                        <td>手续费：<input type="text" name="extraPrice" value="0" style="width: 60px;" onchange="calPrice();" disabled> 元</td>
                                    </tr>
                                    <tr>
                                        <td>总金额：<label name="totalPrice" style="font-weight: bold; font-size: 16px; color:red;" disabled>0.00</label> 元</td>
                                        <td colspan="2">拒绝意见：<textarea id="option" placeholder="请输入审核意见" name="option" style="width: 300px;"></textarea></td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="hr-line-dashed"></div>
                    <div class="form-group text-right" style="width: 100%;position: relative">
                        <div class="col-sm-4 col-sm-offset-2" style="width: 100%;position: absolute;right: 0px;bottom: -30px;">
                            <button id="saveUserBtn" class="btn btn-primary" type="button" onclick="submit()">审核</button>
                            <button id="closeBtn" class="btn btn-white" onclick="closeLayer()" type="button">关闭</button>
                            <input name="verifyStatus" type="hidden">
                        </div>
                    </div>

                    <br><br><br>
                    <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
                        <div id="innerdiv" style="position:absolute;">
                            <img id="bigimg" style="border:5px solid #fff;" src="" />
                        </div>
                    </div>
                </fieldset>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    //步骤条
    /*layui.use(['steps'], function() {
        var $step = $("#step_demo").step({
            header: ['业务受理', '未审核', '复印申请单', '已支付', '未归档', '自提','业务完成','工作单']
        });
        $step.goStep(2);
    });*/
    changeVerify("pass");
    $(".pic").click(function(){
        var _this = $(this);//将当前的pimg元素作为_this传入函数
        imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
    });

    function calPrice() {
        var singlePrice = $("#verify input[name='singlePrice']").val();
        var printCount = $("#printCount").text();
        var transPrice = $("#verify input[name='transPrice']").val();
        var extraPrice = $("#verify input[name='extraPrice']").val();

        var totalPrice = parseFloat(singlePrice)* printCount + parseFloat(transPrice) + parseFloat(extraPrice);
        $("#verify label[name='totalPrice']").text(totalPrice.toFixed(2));
    }

    function closeLayer() {
        parent.closeLayer();
    }
    function closeLayer2(msg) {
        parent.closeLayer2(msg);
    }

    function changeVerify(id) {
        $(".verify-pass-table,.verify-refuse-table").removeAttr("id");

        if(id == "refuse"){
            $(".verify-refuse-table").attr("id","verify");
        }else if(id == "pass"){
            $(".verify-pass-table").attr("id","verify");
        }

        $("input[name='verifyStatus']").val(id);
    }
    var flag = true;
    function submit() {
        if(!flag){
            layer.alert("请不要重复提交");
            return;
        }
        flag = false;
        var verifyStatus = $("input[name='verifyStatus']").val();
        //参数封装
        var verifyInfo = {
            uuid : $("label[id='uuid']").text(),
            verifyStatus : verifyStatus,
            singlePrice : $("#verify input[name='singlePrice']").val(),
            transPrice : $("#verify input[name='transPrice']").val(),
            extraPrice : $("#verify input[name='extraPrice']").val(),
            totalPrice : $("#verify label[name='totalPrice']").text(),
            option : $("#verify #option").val()
        };
        $.ajax({
            type: "POST",
            url: "/sys/app/verify",
            dataType: "json",
            data:JSON.stringify(verifyInfo),
            contentType:"application/json",
            success: function (result) {
                if(result.code == '1'){
                    closeLayer2(result.msg);
                }else {
                    layer.alert("审核操作失败，"+result.msg);
                    flag = true;
                }
            },
            error: function (result) {
                layer.alert("审核操作失败，"+result);
                flag = true;
            }
        });
    }

    layui.use('element', function(){
        var $ = layui.jquery
            ,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        element.on('tab(tab-verify)',function(data){
            // console.log(this); //当前Tab标题所在的原始DOM元素
            // console.log(data.index); //得到当前Tab的所在下标
            // console.log(data.elem); //得到当前的Tab大容器

            console.log((data.elem)[0]);
            var idVal = $(this).attr("id");
            changeVerify(idVal);
        });
    });

    function imgShow(outerdiv, innerdiv, bigimg, _this){
        var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
        $(bigimg).attr("src", src);//设置#bigimg元素的src属性
        /*获取当前点击图片的真实大小，并显示弹出层及大图*/
        $("<img/>").attr("src", src).load(function(){
            var windowW = $(window).width();//获取当前窗口宽度
            var windowH = $(window).height();//获取当前窗口高度
            var realWidth = this.width;//获取图片真实宽度
            var realHeight = this.height;//获取图片真实高度
            var imgWidth, imgHeight;
            var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放
            if(realHeight>windowH*scale) {//判断图片高度
                imgHeight = windowH*scale;//如大于窗口高度，图片高度进行缩放
                imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
                if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
                    imgWidth = windowW*scale;//再对宽度进行缩放
                }
            } else if(realWidth>windowW*scale) {//如图片高度合适，判断图片宽度
                imgWidth = windowW*scale;//如大于窗口宽度，图片宽度进行缩放
                imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
            } else {//如果图片真实高度和宽度都符合要求，高宽不变
                imgWidth = realWidth;
                imgHeight = realHeight;
            }
            $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放
            var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
            var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
            $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
            $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
        });
        $(outerdiv).click(function(){//再次点击淡出消失弹出层
            $(this).fadeOut("fast");
        });
    }

    $(".ipt").on('input  propertychange',function(){
        //确保输入的是数字
        this.value = this.value.replace(/[^\d\.]/g, '');
        //确保第一个输入的是数字
        this.value = this.value.replace(/^\./g,'');
        //前两位不能是0加数字
        this.value = this.value.replace(/^0\d[0-9]*/g,'');
        //确保不能输入两个小数点
        this.value = this.value.replace(/\.{2,}/g,'.');
        //保证小数点只出现一次，而不能出现两次以上
        this.value = this.value.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
        //确保只能输入两位小数
        this.value = this.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
    })

    $(".ipt").click(function () {
        $(this).focus().select();
        this.selectionStart = 0;
        this.selectionEnd = this.val().length;
    })

    $(".ipt").blur(function(){
        //如果输入框为空，则替换为0.00
        if(this.value == ""){
            this.value = "0.00";
            calPrice();
        }
    })
</script>

</body>
</html>